Option Strict Off
Option Explicit On

Namespace BMLERP
	Public Class FrmMainMenu
		Inherits System.Windows.Forms.Form

		Public Sub a_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles a.Click
			Dim Index As Short = a.GetIndex(eventSender)
			Select Case Index

			End Select
		End Sub

		Public Sub a1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles a1.Click
			Dim Index As Short = a1.GetIndex(eventSender)
			Select Case Index
				Case 1
					Dim mform As New frmACR100
					mform.ShowDialog()
					'frmACR100.ShowDialog()
				Case 2
					Dim mform As New frmACR110
					mform.ShowDialog()
					'frmACR110.ShowDialog()
			End Select
		End Sub

		Public Sub a2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles a2.Click
			Dim Index As Short = a2.GetIndex(eventSender)
			Select Case Index
				Case 1
					Dim mform As New frmACR105
					mform.ShowDialog()
					'frmACR105.ShowDialog()
				Case 2
					Dim mform As New frmACR115
					mform.ShowDialog()
					' frmACR115.ShowDialog()
			End Select
		End Sub

		Public Sub a4_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles a4.Click
			Dim Index As Short = a4.GetIndex(eventSender)
			Select Case Index
				Case 1
					Dim mform As New frmRAR500
					mform.ShowDialog()
					' frmRAR500.ShowDialog()
				Case 2
			End Select
		End Sub

		Public Sub g1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles g1.Click
			Dim Index As Short = g1.GetIndex(eventSender)
			Select Case Index
				Case 1
					'    frmgld100.Show 1
				Case 2
					'    frmgld110.Show 1
				Case 3
					'    frmgld120.Show 1
				Case 4
					'    frmgld130.Show 1
				Case 5
					'    frmgld140.Show 1
				Case 6
					frmGLD150.ShowDialog()
				Case 7
					Dim mform As New frmGLD160
					mform.ShowDialog()
					'frmGLD160.ShowDialog()
			End Select
		End Sub

		Public Sub i1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles i1.Click
			Dim Index As Short = i1.GetIndex(eventSender)
			Select Case Index
				Case 1
					frmINV100.ShowDialog()
				Case 2
					frmINV110.ShowDialog()
				Case 3
					frmINV120.ShowDialog()
				Case 4
					Dim mform As New frmINV130
					mform.ShowDialog()

					'frmINV130.ShowDialog()
				Case 5
					Dim mform As New frmINV140
					mform.ShowDialog()
					'frmINV140.ShowDialog()
				Case 6
					Dim mform As New frmINV150
					mform.ShowDialog()
					'frmINV150.ShowDialog()
				Case 7
					Dim mform As New frmINV160
					mform.ShowDialog()
					' frmINV160.ShowDialog()
			End Select

		End Sub

		Public Sub i2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles i2.Click
			Dim Index As Short = i2.GetIndex(eventSender)
			Select Case Index
				Case 1
					frmINV105.ShowDialog() 'Item Master
				Case 2
					frmINV115.ShowDialog() 'Warehouse
				Case 3
					frmINV125.ShowDialog() 'Lot
				Case 4
					Dim mform As New frmINV135
					mform.ShowDialog()
					'frmINV135.ShowDialog() 'Type
				Case 5
					Dim mform As New frmINV145
					mform.ShowDialog()
					'frmINV145.ShowDialog() 'Class
				Case 6
					Dim mform As New frmINV155
					mform.ShowDialog()
					' frmINV155.ShowDialog() 'Unit Of Measurement
				Case 7
					Dim mform As New frmINV165
					mform.ShowDialog()
					' frmINV165.ShowDialog() 'Transaction Effect code
			End Select
		End Sub

		Public Sub i3_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles i3.Click
			Dim Index As Short = i3.GetIndex(eventSender)
			Dim ReportName As String
			Reportflg = True

			Select Case Index
				Case 1
					frmINV200.ShowDialog()
				Case 2
					ReportName = "RECEIVE_DETAIL.rpt"
				Case 3
					ReportName = "ISSUED_DETAIL.rpt"

				Case 4
					ReportName = "stockmoment.rpt"
			End Select
			If Index <> 1 And Index <> 4 Then
				FrmReportDateRange.ShowDialog()
				If Reportflg = False Then
					Exit Sub
				End If
				CrystalReport1.ReportFileName = DDAN & "\" & ReportName
				CrystalReport1.RetrieveStoredProcParams()
				CrystalReport1.set_StoredProcParam(0, VB6.Format(FrmReportDateRange.bdate.Text, "mm/dd/yy"))
				CrystalReport1.set_StoredProcParam(1, VB6.Format(FrmReportDateRange.edate.Text, "mm/dd/yy"))
				CrystalReport1.Action = 1
				FrmReportDateRange.Close()
			ElseIf Index = 4 Then
				FrmReportDateRange.FrmeOption.Enabled = True
				FrmReportDateRange.ShowDialog()

				If Reportflg = False Then
					Exit Sub
				End If
				CrystalReport1.ReportFileName = DDAN & "\" & ReportName
				CrystalReport1.RetrieveStoredProcParams()
				CrystalReport1.set_StoredProcParam(0, VB6.Format(FrmReportDateRange.bdate.Text, "mm/dd/yy"))
				CrystalReport1.set_StoredProcParam(1, VB6.Format(FrmReportDateRange.edate.Text, "mm/dd/yy"))
				If FrmReportDateRange.Option1.Checked = True Then
					CrystalReport1.set_StoredProcParam(2, "0")
				ElseIf FrmReportDateRange.Option2.Checked = True Then
					CrystalReport1.set_StoredProcParam(2, "1")
				End If
				CrystalReport1.Action = 1
				FrmReportDateRange.Close()
			End If
		End Sub

		Public Sub i4_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles i4.Click
			Dim Index As Short = i4.GetIndex(eventSender)
			' Dim frmINV300 As Object
			Select Case Index
				Case 1
					'frmINV300.Show(1)
			End Select
		End Sub

		Public Sub i5_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles i5.Click
			Dim Index As Short = i5.GetIndex(eventSender)
			Select Case Index
				Case 1
					frmINV500.ShowDialog()
				Case 2
					Dim mform As New frmINV540
					mform.ShowDialog()
					'frmINV540.ShowDialog()
				Case 3
					FrmReceived.Show()
			End Select
		End Sub

		Public Sub i6_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles i6.Click
			Dim Index As Short = i6.GetIndex(eventSender)
			Select Case Index
				Case 1 ' PeriodEndClosing
					INV900()
				Case 2 ' Year End Closing
					INV910()
			End Select
		End Sub

		Public Sub Iv_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles iv.Click
			Dim Index As Short = iv.GetIndex(eventSender)
			Select Case Index
				Case 1 ' BBL400 print invoice
					Dim mform As New frmBBL400
					mform.ShowDialog()

					'frmBBL400.ShowDialog()
				Case 2 ' BBL410 Re-print invoice
					frmBBL410.ShowDialog()
				Case 3
				Case 4
				Case 5 ' BBL 500 Invoice entry
					Dim mform As New frmBBL500
					mform.ShowDialog()
					'frmBBL500.ShowDialog()
				Case 6
					'BBL510
					frmBBL_ConvOrdInv.ShowDialog()
				Case 7
					Dim mform As New frmregist
					frmregist.ShowDialog()
					' frmregist.ShowDialog()
			End Select
		End Sub

		Public Sub l_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles l.Click
			Dim Index As Short = l.GetIndex(eventSender)
			Select Case Index
				Case 1
					Dim mform As New frmSAL100
					mform.ShowDialog()
					'frmSAL100.ShowDialog()
				Case 2

			End Select
		End Sub

		Public Sub l2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles l2.Click
			Dim Index As Short = l2.GetIndex(eventSender)
			Select Case Index
				Case 1
					frmSell.ShowDialog()
			End Select
		End Sub

		Private Sub FrmMainMenu_Activated(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Activated
			Dim Old_User As String
			'Dim i As Integer
			Old_User = UserName
			'If UserLogin = "" Then
			'     UserName = FrmLogin.Tag
			'End If
			If UserName = "" Then
				UserName = FrmLogin.Tag
			End If
			FrmLogin.Close()
			If UserName <> "" And UserName <> Old_User Then
				Picture1.Visible = True
				SetMenuPad()
				' Picture1.Visible = False
			Else
				If UserLogin = "" Then
					Me.Close()
				End If
			End If
		End Sub

		Private Sub FrmMainMenu_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
			If Not InitSuccess Then
				BIENCHUNG()
			End If

			FrmLogin.ShowDialog()
		End Sub

		Private Sub FrmMainMenu_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
			If DBconn.State = ADODB.ObjectStateEnum.adStateOpen Then
				DBconn.Close()
				Me.Close()
			End If
			' Else
			' Me.Close()
			'End If
		End Sub

		Public Sub o_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles o.Click
			Dim Index As Short = o.GetIndex(eventSender)
			Select Case Index
				Case 5
					Dim mform As New frmORD500
					mform.ShowDialog()
					'frmORD500.ShowDialog()
				Case 7
					Dim mform As New frmORD540
					mform.ShowDialog()
					'frmORD540.ShowDialog()
				Case 9
					Dim mform As New frmORD560
					mform.ShowDialog()
					'frmORD560.ShowDialog()
				Case 10
					' FrmOrd600.Show(1)
			End Select
		End Sub

		Public Sub o1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles o1.Click
			Dim Index As Short = o1.GetIndex(eventSender)
			Select Case Index
				Case 1
				Case 2
					Dim mform As New frmORD110
					mform.ShowDialog()
					'frmORD110.ShowDialog()
				Case 3
					Dim mform As New frmORD120
					mform.ShowDialog()
					'frmORD120.ShowDialog()
				Case 4
					Dim mform As New frmORD130
					mform.ShowDialog()
					' frmORD130.ShowDialog()
			End Select
		End Sub

		Public Sub p_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles p.Click
			Dim Index As Short = p.GetIndex(eventSender)
			Select Case Index
				Case 3
					Dim myform As New frmPUR200
					myform.Show()
					'frmPUR200.ShowDialog()
				Case 4
					Dim myform As New frmPUR210
					myform.Show()
					'frmPUR210.ShowDialog()
				Case 5
					Dim myform As New frmPUR500
					myform.Show()
					'frmPUR500.ShowDialog()
				Case 6
					Dim myform As New frmPUR510
					myform.Show()
					'frmPUR510.ShowDialog()
			End Select
		End Sub

		Public Sub p1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles p1.Click
			Dim Index As Short = p1.GetIndex(eventSender)
			Select Case Index
				Case 1
					Dim myform As New FrmPOReport
					myform.Show()
					'FrmPOReport.ShowDialog()
				Case 2
					Dim myform As New frmPUR220
					myform.Show()
					'frmPUR220.ShowDialog()
				Case 3
					Dim myform As New frmcust
					myform.Show()
					'frmcust.ShowDialog()
			End Select
		End Sub

		Public Sub s_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles s.Click
			Dim Index As Short = s.GetIndex(eventSender)
			Select Case Index
				Case 1
					FrmLogin.ShowDialog()
				Case 2
					frmStaff.ShowDialog()
				Case 3
					frmChangePassword.ShowDialog()
				Case 4
					frmAdmin.ShowDialog()
				Case 5
					DBconn.Close()
					Me.Close()
					End
			End Select
		End Sub

		Public Sub y_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles y.Click
			Dim Index As Short = y.GetIndex(eventSender)
			Select Case Index
				Case 1
					frmACP100.ShowDialog()
				Case 2
			End Select
		End Sub

		Sub SetMenuPad()
			Dim RecMenuPad As ADODB.Recordset
			RecMenuPad = DBconn.Execute("SELECT MenuPad.PadName,MenuPad.PadIndex" & " FROM MenuPad INNER JOIN" & " GroupFunction ON MenuPad.PadCode = GroupFunction.Padcode INNER JOIN" & " UserGroup ON GroupFunction.UserGroup = UserGroup.UserGroup" & " WHERE UserGroup.UserGroup <> '" & NhomLogin & "'")
			'An nhung menu khong duoc phep
			Do While Not RecMenuPad.EOF
				Dim padindex As Integer
				Dim padname As String
				padname = RecMenuPad.Fields("PadName").Value
				padindex = RecMenuPad.Fields("PadIndex").Value
				If InStr(1, RecMenuPad.Fields("PadName").Value, "mn", 0) > 0 Then
					SetMenu_mn(padname, padindex, False)
				Else
					If InStr(1, RecMenuPad.Fields("PadName").Value, "i", 0) > 0 Then

						SetMenu_i(padname, padindex, False)
					Else
						If InStr(1, RecMenuPad.Fields("PadName").Value, "a", 0) > 0 Then
							SetMenu_a(padname, padindex, False)
						Else
							If InStr(1, RecMenuPad.Fields("PadName").Value, "p", 0) > 0 Then
								SetMenu_p(padname, padindex, False)
							Else
								If InStr(1, RecMenuPad.Fields("PadName").Value, "o", 0) > 0 Then
									SetMenu_o(padname, padindex, False)
								Else
									If InStr(1, RecMenuPad.Fields("PadName").Value, "iv", 0) > 0 Then
										SetMenu_iv(padname, padindex, False)
									Else
										If InStr(1, RecMenuPad.Fields("PadName").Value, "l", 0) > 0 Then
											SetMenu_l(padname, padindex, False)
										Else
											If InStr(1, RecMenuPad.Fields("PadName").Value, "y", 0) > 0 Then
												SetMenu_y(padname, padindex, False)
											Else
												If InStr(1, RecMenuPad.Fields("PadName").Value, "g", 0) > 0 Then
													SetMenu_g(padname, padindex, False)
												Else
													If InStr(1, RecMenuPad.Fields("PadName").Value, "s", 0) > 0 Then
														SetMenu_s(padname, padindex, False)
													End If
												End If
											End If
										End If
									End If
								End If
							End If
						End If
					End If
				End If
				RecMenuPad.MoveNext()

			Loop

			RecMenuPad = DBconn.Execute("SELECT MenuPad.PadName,MenuPad.PadIndex" & " FROM MenuPad INNER JOIN" & " GroupFunction ON MenuPad.PadCode = GroupFunction.Padcode INNER JOIN" & " UserGroup ON GroupFunction.UserGroup = UserGroup.UserGroup" & " WHERE UserGroup.UserGroup = '" & NhomLogin & "'")

			Do While Not RecMenuPad.EOF	'SEt menu duoc phep
				Dim padindex As Integer
				Dim padname As String
				padname = RecMenuPad.Fields("PadName").Value
				padindex = RecMenuPad.Fields("PadIndex").Value
				If InStr(1, RecMenuPad.Fields("PadName").Value, "mn", 0) > 0 Then
					SetMenu_mn(padname, padindex, True)
				Else
					If InStr(1, RecMenuPad.Fields("PadName").Value, "i", 0) > 0 Then
						SetMenu_i(padname, padindex, True)
					Else
						If InStr(1, RecMenuPad.Fields("PadName").Value, "a", 0) > 0 Then
							SetMenu_a(padname, padindex, True)
						Else
							If InStr(1, RecMenuPad.Fields("PadName").Value, "p", 0) > 0 Then
								SetMenu_p(padname, padindex, True)
							Else
								If InStr(1, RecMenuPad.Fields("PadName").Value, "o", 0) > 0 Then
									SetMenu_o(padname, padindex, True)
								Else
									If InStr(1, RecMenuPad.Fields("PadName").Value, "iv", 0) > 0 Then
										SetMenu_iv(padname, padindex, True)
									Else
										If InStr(1, RecMenuPad.Fields("PadName").Value, "l", 0) > 0 Then
											SetMenu_l(padname, padindex, True)
										Else
											If InStr(1, RecMenuPad.Fields("PadName").Value, "y", 0) > 0 Then
												SetMenu_y(padname, padindex, True)
											Else
												If InStr(1, RecMenuPad.Fields("PadName").Value, "g", 0) > 0 Then
													SetMenu_g(padname, padindex, True)
												Else
													If InStr(1, RecMenuPad.Fields("PadName").Value, "s", 0) > 0 Then
														SetMenu_s(padname, padindex, True)
													End If
												End If
											End If
										End If
									End If
								End If
							End If
						End If
					End If
				End If
				RecMenuPad.MoveNext()
			Loop
			RecMenuPad.Close()
		End Sub

		Sub SetMenu_mn(ByRef PadName As String, ByRef PadIndex As Integer, ByRef Enable As Boolean)
			mn.Item(PadIndex).Enabled = Enable
		End Sub

		Sub SetMenu_i(ByRef PadName As String, ByRef PadIndex As Integer, ByRef Enable As Boolean)
			Select Case PadName
				Case "i"
					i.Item(PadIndex).Enabled = Enable
				Case "i1"
					i1.Item(PadIndex).Enabled = Enable
				Case "i2"
					i2.Item(PadIndex).Enabled = Enable
				Case "i3"
					i3.Item(PadIndex).Enabled = Enable
				Case "i4"
					i4.Item(PadIndex).Enabled = Enable
				Case "i5"
					i5.Item(PadIndex).Enabled = Enable
				Case "i6"
					i6.Item(PadIndex).Enabled = Enable
			End Select
		End Sub

		Sub SetMenu_a(ByRef PadName As String, ByRef PadIndex As Integer, ByRef Enable As Boolean)
			Select Case PadName
				Case "a"
					a.Item(PadIndex).Enabled = Enable
				Case "a1"
					a1.Item(PadIndex).Enabled = Enable
				Case "a2"
					a2.Item(PadIndex).Enabled = Enable
				Case "a3"
					a3.Item(PadIndex).Enabled = Enable
				Case "a4"
					a4.Item(PadIndex).Enabled = Enable
					' Case "a5"
					'     a5.Item(PadIndex).Enabled = enable
					' Case "a6"
					'     a6.Item(PadIndex).Enabled = enable
			End Select
		End Sub

		Sub SetMenu_p(ByRef PadName As String, ByRef PadIndex As Integer, ByRef Enable As Boolean)
			Select Case PadName
				Case "p"
					p.Item(PadIndex).Enabled = Enable
			End Select
		End Sub

		Sub SetMenu_o(ByRef PadName As String, ByRef PadIndex As Integer, ByRef Enable As Boolean)
			Select Case PadName
				Case "o"
					o.Item(PadIndex).Enabled = Enable
				Case "o1"
					o1.Item(PadIndex).Enabled = Enable
				Case "o2"
					o2.Item(PadIndex).Enabled = Enable
				Case "o3"
					o3.Item(PadIndex).Enabled = Enable
			End Select
		End Sub

		Sub SetMenu_iv(ByRef PadName As String, ByRef PadIndex As Integer, ByRef Enable As Boolean)
			Select Case PadName
				Case "iv"
					iv.Item(PadIndex).Enabled = Enable
			End Select
		End Sub

		Sub SetMenu_l(ByRef PadName As String, ByRef PadIndex As Integer, ByRef Enable As Boolean)
			Select Case PadName
				Case "l"
					l.Item(PadIndex).Enabled = Enable
				Case "l2"
					l2.Item(PadIndex).Enabled = Enable
			End Select
		End Sub

		Sub SetMenu_y(ByRef PadName As String, ByRef PadIndex As Integer, ByRef Enable As Boolean)
			Select Case PadName
				Case "y"
					y.Item(PadIndex).Enabled = Enable
				Case "y3"
					y3.Item(PadIndex).Enabled = Enable
			End Select
		End Sub

		Sub SetMenu_g(ByRef PadName As String, ByRef PadIndex As Integer, ByRef Enable As Boolean)
			Select Case PadName
				Case "g"
					g.Item(PadIndex).Enabled = Enable
				Case "g1"
					g1.Item(PadIndex).Enabled = Enable
				Case "g2"
					g2.Item(PadIndex).Enabled = Enable
				Case "g3"
					g3.Item(PadIndex).Enabled = Enable
				Case "g4"
					g4.Item(PadIndex).Enabled = Enable
				Case "g5"
					g5.Item(PadIndex).Enabled = Enable
				Case "g6"
					g6.Item(PadIndex).Enabled = Enable
			End Select
		End Sub

		Sub SetMenu_s(ByRef PadName As String, ByRef PadIndex As Integer, ByRef Enable As Boolean)
			Select Case PadName
				Case "s"
					s.Item(PadIndex).Enabled = Enable
			End Select
		End Sub

		Private Sub ScrStatus(ByRef formnme As String)
			Select Case formnme
				Case "ord500"
					frmORD500.lbl(33).Visible = False
					frmORD500.lbl(34).Visible = False
				Case "ord560"
					frmORD500.cmdReview.Visible = False
					frmORD500.cmdAddNew.Visible = False
					frmORD500.cmdNewItem.Visible = False
					frmORD500.cmdSave.Visible = False
					frmORD500.lbl(0).Visible = False
					frmORD500.lbl(1).Visible = False
			End Select
		End Sub

		Private Sub _i1_1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _i1_1.Click
		End Sub
	End Class
End Namespace